package com.comment.project.oss;

import java.io.File;
import java.io.IOException;

import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.*;

/**
 * @author liupenghui
 * @date 2018/7/26
 * @desc：
 */
public class ImageSample {
    private static String endpoint = "http://oss-cn-beijing.aliyuncs.com";
    private static String accessKeyId = "LTAIv2HaWLvh3TUB";
    private static String accessKeySecret = "HtfWNa1LO2ZI2aYqZ7OQ073zeah2rO";
    private static String bucketName = "skrskr";
    private static String key = "gou.jpg";

    public static void main(String[] args) {
        OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);

        // 新建存储空间默认为标准存储类型，私有权限。
///        ossClient.createBucket(bucketName);
        CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName);
// 设置存储空间的权限为公共读，默认是私有。
        createBucketRequest.setCannedACL(CannedAccessControlList.PublicRead);
// 设置存储空间的存储类型为低频访问类型，默认是标准类型。
        createBucketRequest.setStorageClass(StorageClass.IA);
        ossClient.createBucket(createBucketRequest);


        // 获取存储空间的访问权限。
        AccessControlList acl = ossClient.getBucketAcl(bucketName);
        System.out.println(acl.toString());


        // 关闭OSSClient。
        ossClient.shutdown();
    }

}
